#include "mcounter.h"

#include <QPainter>
#include <iostream>

MCounter::MCounter(QGraphicsItem *parent) :
    QGraphicsWidget(parent)
{
    rest = -1;
}

void MCounter::setNumber(int r)
{
    rest = r;
    update();
}

void MCounter::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
{
    if (rest < 0)
        return;
    QFont f;
    f.setPixelSize(12);
    if (rest <= 3)
    {
        f.setBold(true);
        p->setPen(QColor(255, 0, 0));
    }

    p->setFont(f);
    p->drawText(-10, 0, QString("[%1]").arg(rest));
}
